<template>
  <div id="zhidu">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item><b>数据更新日志</b></el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxd">
      <!--列表-->
      <h1>数据更新日志</h1>
      <el-table :data="updateLogList" highlight-current-row v-loading="LogListLoading" style="width: 100%;" :height="tableHeight" border>
        <el-table-column type="index" label=" " width="50" fixed align="center" class-name="tableth">
        </el-table-column>
          <el-table-column label="操作时间" width="200">
            <template slot-scope="scope">
              <i class="el-icon-success" style="color:#090" v-if="scope.row.chenggong==='成功'"></i>
              <i class="el-icon-error" style="color:#f00" v-if="scope.row.chenggong==='失败'"></i>
              {{scope.row.thedatetime}}
            </template>
          </el-table-column>
          <el-table-column prop="filename" label="文件名" width="340">
          </el-table-column>
          <el-table-column prop="zhixingshijian" label="执行时长(毫秒)" width="130">
          </el-table-column>
          <el-table-column prop="errormsg" label="备注">
          </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination :total="logTotalNum" :current-page="logPageNum" :page-size="logPageSize" @current-change="loghandleCurrentChange" @size-change="loghandleSizeChange" :page-sizes="[10, 20, 30, 50]" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  data () {
    return {
      updateLogText: {},
      updateLogList: [],
      LogListLoading: false,
      logTotalNum: 0,
      logPageNum: 1,
      logPageSize: 20,
      tableHeight: 100
    }
  },
  methods: {
    loghandleSizeChange (val) {
      this.changeLogSizeFlag = true
      this.logPageNum = 1
      this.logPageSize = val
      this.getUpdatelogList()
    },
    loghandleCurrentChange (val) {
      if (this.changeLogSizeFlag === false) {
        this.logPageNum = val
        this.getUpdatelogList()
      }
    },
    getUpdatelogList () {
      this.LogListLoading = true
      let para = {}
      para = {
        pageNum: this.logPageNum,
        pageSize: this.logPageSize
      }
      var _this = this
      this.$http
        .post('/dlog/details', para)
        .then(function (response) {
          _this.updateLogList = response.data.list
          _this.logTotalNum = response.data.total
          _this.LogListLoading = false
          _this.changeLogSizeFlag = false
        })
        .catch(function (error) {
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - 219
      })
    }
  },
  mounted () {
    this.getUpdatelogList()
    this.tableresize(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.tableresize(_this)
    }
  }
}
</script>
<style>
  .wboxd .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体'
  }
  .wboxd .el-table td{
    padding:5px 0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体'
  }
  .tableth{
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  }
  #zhidu .el-form-item{
    font-size:var(--size14) !important;
    font-family: '宋体';
    margin:0 10px 0 0;
  }
  #zhidu .el-form-item__label{
    font-size:var(--size14) !important;
    font-family: '宋体'
  }
  #zhidu .el-input__inner{
    font-size:var(--size14) !important;
    line-height: 20px;
    height:30px;
    padding: 5px;
    border-radius: 0;
  }
  #zhidu .el-button{
    padding: 7px;
    border-radius: 0;
  }
</style>
<style scoped>
  h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  .el-pagination{
    float: left;
    padding:7px 10px;
  }
  .wboxs{
    padding:5px 15px;
    width: calc(100% - 30px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
  .wboxd{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
</style>
